package br.comdecorando.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import br.com.decorando.model.Perfil;

import br.com.decorando.activity.R;

public class MainAdapter extends ArrayAdapter<Perfil> {
	private List<Perfil> itens;
	private int layoutResourceId;
	private Context context;		
	
	public MainAdapter(Context context, int layoutResourceId, List<Perfil> itens) {
		super(context, layoutResourceId, itens);
		this.context = context;
		this.layoutResourceId = layoutResourceId;
		this.itens = itens;
	}
	
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Perfil perfil = itens.get(position);		
		LayoutInflater inflater = ((Activity) context).getLayoutInflater();
		View row = inflater.inflate(layoutResourceId, parent, false);
		TextView nome = (TextView) row.findViewById(R.id.txvNomePerfil);
		Log.d("View", String.valueOf(position));
		Log.d("View", perfil.getName());
		nome.setText(perfil.getName());				
		row.setTag(perfil.getId());
		return row;
	}			
}
